<?php
/**
 * @todo 首页幻灯片切换效果
 * @author shenjun
 *
 */
class SlidePic extends CWidget{
	//需要展示的图片
	public $pic = array();
	//切换速度
	public $time = 3000 ;
	
	public function run(){
		$language = strtoupper( Yii::app()->session->offSetGet( "FrontLanguage" ) );
		$datas = Indexpic::model()->findAll( 'ID>:ID ORDER BY :order ASC ' , array(
			':ID' => 0 ,
			':order' =>'Sorts' 
		) );		
		
		$html="";
		$coltitle=$language."Title";
		foreach ($datas as $dkel=>$dval){
			$html.='<li><a target="_blank" href="'.$dval->Link.'"><img src="'.$dval->PicPath.'" width="701" height="257" alt="'.$dval->$coltitle.'" /></a></li>';
		}
		echo '<div class="banner smallslider" id="Yii_SlidePic">
					'.$html.'
			  </div>';
		$this->addJs();
	}
	
	public function addJs(){
		Yii::app()->clientScript->registerScriptFile( Yii::app()->clientScript->getCoreScriptUrl() . '/jquery.smallslider.js');	
		Yii::app()->clientScript->registerCssFile( Yii::app()->request->baseURL . 'css/smallsilder/smallslider.css');
		Yii::app()->clientScript->registerScript( 'Yii_SlidePic' , "$('#Yii_SlidePic').smallslider({
			onImageStop : false ,
			time : {$this->time}, 
			showText : true
		});");
	}
}